From d4d4227dfb2fefa56ded8ff5897469459f56b069 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 2 Feb 2023 17:13:12 +0700 Subject: no message --- src/pages/shop/product/[slug].js | 78 ++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 27 deletions(-) (limited to 'src/pages/shop/product/[slug].js') diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js index bcfb12ba..281f2bc2 100644 --- a/src/pages/shop/product/[slug].js +++ b/src/pages/shop/product/[slug].js @@ -138,6 +138,23 @@ export default function ProductDetail({ product }) { return true; } + const checkoutProduct = () => { + if (!auth) { + toast.error('Login terlebih dahulu untuk melanjutkan', { duration: 2000 }); + router.push('/login'); + return; + } + if (product.variant_total > 1 && !selectedVariant) { + toast.error('Pilih varian terlebih dahulu untuk melanjutkan pembelian', { duration: 2000 }); + return; + } + if (quantity < 0) { + toast.error('Jumlah barang yang ditambahkan minimal 1 pcs', { duration: 2000 }); + return; + } + router.push(`/shop/checkout?product_id=${activeVariant.id}&qty=${quantity}`); + } + return ( <>
@@ -187,36 +204,38 @@ export default function ProductDetail({ product }) {
-
-
- - -
-
- - -
+
+ +
+
- + + +
@@ -230,7 +249,7 @@ export default function ProductDetail({ product }) {

{product.variant_total} Varian

-

Nomor SKU

+

No. SKU

SKU-{activeVariant.id}

@@ -239,9 +258,14 @@ export default function ProductDetail({ product }) {

Stok

-

- {activeVariant.stock > 0 ? (activeVariant.stock > 5 ? 'Lebih dari 5' : 'Kurang dari 5') : '0'} -

+
+ {activeVariant.stock > 0 ? (activeVariant.stock > 5 && ( + <> +
Ready Stock
+
{activeVariant.stock > 5 ? '> 5' : '< 5'}
+ + )) : '0'} +

Berat Barang

@@ -259,7 +283,7 @@ export default function ProductDetail({ product }) {
-

Produk Lainnya

+

Kamu Mungkin Juga Suka

-- cgit v1.2.3